﻿<UserControl x:Class="LaunchPad2.Controls.LibraryPanel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:viewModels="clr-namespace:LaunchPad2.ViewModels"
             mc:Ignorable="d" Background="#252526"
             d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignData ViewModel}">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <TextBlock Text="Library" Margin="6" Foreground="{DynamicResource MenuTextBrushKey}"/>

        <Grid Grid.Row="1">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
            </Grid.ColumnDefinitions>
            <Button Command="{Binding AddDeviceCommand}" ToolTip="Add Device" HorizontalAlignment="Left" Background="Transparent" BorderThickness="0" Margin="3,0,3,3" Template="{StaticResource ButtonTemplate}">
                <Viewbox Stretch="Uniform" Width="16" Height="16">
                    <Grid>
                        <Path Data="{DynamicResource RocketGeometryKey}" Fill="{DynamicResource MenuBlueBrushKey}" HorizontalAlignment="Left" Height="26" Stretch="Fill" VerticalAlignment="Top" Width="26" />
                        <Path Data="{DynamicResource NewStarGeometryKey}" Fill="{DynamicResource MenuBrownBrushKey}" HorizontalAlignment="Left" VerticalAlignment="Top" Height="12" Stretch="Fill" Width="12"/>
                    </Grid>
                </Viewbox>
            </Button>
            <Button Command="{Binding DeleteDeviceCommand}" ToolTip="Delete Device" Grid.Column="1" HorizontalAlignment="Left" Background="Transparent" BorderThickness="0" Margin="0,0,3,3" Template="{StaticResource ButtonTemplate}">
                <Button.Style>
                    <Style TargetType="Button">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ElementName=DeviceListView, Path=SelectedItem}" Value="{x:Null}">
                                <Setter Property="IsEnabled" Value="False"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Button.Style>
                <Viewbox Stretch="Uniform" Width="16" Height="16">
                    <Grid>
                        <Path Data="{DynamicResource RocketGeometryKey}" HorizontalAlignment="Left" Height="26" Stretch="Fill" VerticalAlignment="Top" Width="26" >
                            <Path.Style>
                                <Style TargetType="Path">
                                    <Setter Property="Fill" Value="{DynamicResource MenuBlueBrushKey}"/>
                                    <Style.Triggers>
                                        <Trigger Property="IsEnabled" Value="False">
                                            <Setter Property="Fill" Value="{StaticResource MenuDisabledBrushKey}"/>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </Path.Style>
                        </Path>
                        <Path Data="{DynamicResource DeleteGeometryKey}" HorizontalAlignment="Left" VerticalAlignment="Top" Height="12" Stretch="Fill" Width="12">
                            <Path.Style>
                                <Style TargetType="Path">
                                    <Setter Property="Fill" Value="{DynamicResource MenuRedBrushKey}"/>
                                    <Style.Triggers>
                                        <Trigger Property="IsEnabled" Value="False">
                                            <Setter Property="Fill" Value="{StaticResource MenuDisabledBrushKey}"/>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </Path.Style>
                        </Path>
                    </Grid>
                </Viewbox>
            </Button>
            <Button Command="{Binding AddTrackFromDeviceCommand}" CommandParameter="{Binding ElementName=DeviceListView, Path=SelectedItem}" 
                    Grid.Column="2" HorizontalAlignment="Left" Background="Transparent" BorderThickness="0" Margin="0,0,3,3" Template="{StaticResource ButtonTemplate}">
                <Button.Style>
                    <Style TargetType="Button">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding ElementName=DeviceListView, Path=SelectedItem}" Value="{x:Null}">
                                <Setter Property="IsEnabled" Value="False"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Button.Style>
                <Viewbox Stretch="Uniform" Height="14.208" Width="32">
                    <Grid>
                        <Path Data="{DynamicResource TrackGeometryKey}" HorizontalAlignment="Left" Height="9.625" Stretch="Fill" VerticalAlignment="Top" Width="38.625" Margin="4.5,4.583,0,0">
                            <Path.Style>
                                <Style TargetType="Path">
                                    <Setter Property="Fill" Value="{DynamicResource MenuBlueBrushKey}"/>
                                    <Style.Triggers>
                                        <Trigger Property="IsEnabled" Value="False">
                                            <Setter Property="Fill" Value="{StaticResource MenuDisabledBrushKey}"/>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </Path.Style>
                        </Path>
                        <Path HorizontalAlignment="Left" VerticalAlignment="Top" Data="{DynamicResource NewStarGeometryKey}" Height="9.084" Stretch="Fill" Width="9.08">
                            <Path.Style>
                                <Style TargetType="Path">
                                    <Setter Property="Fill" Value="{DynamicResource MenuBrownBrushKey}"/>
                                    <Style.Triggers>
                                        <Trigger Property="IsEnabled" Value="False">
                                            <Setter Property="Fill" Value="{StaticResource MenuDisabledBrushKey}"/>
                                        </Trigger>
                                    </Style.Triggers>
                                </Style>
                            </Path.Style>
                        </Path>
                    </Grid>
                </Viewbox>
            </Button>
        </Grid>
 
        <Border Grid.Row="2" BorderBrush="{DynamicResource PanelHorizontalLineBrushKey}" BorderThickness="0,1,0,0"/>

        <ListView Name="DeviceListView" Grid.Row="3" ItemsSource="{Binding Devices}" Background="{DynamicResource PanelBackgroundBrushKey}" BorderThickness="0"
                 SelectedItem="{Binding SelectedItem}" SelectionMode="Single" >
            <ListBox.ItemTemplate>
                <DataTemplate DataType="{x:Type viewModels:DeviceViewModel}">
                    <TextBlock Foreground="{DynamicResource MenuTextBrushKey}" Text="{Binding Name}"/>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListView>
    </Grid>
</UserControl>
